Source for file SC_MobileImage.php
Documentation is available at SC_MobileImage.php
* This file is part of EC-CUBE
* Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
* http://www.lockon.co.jp/
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
define("MOBILE_IMAGE_INC_PATH", realpath(dirname( __FILE__ )) . "/../include");
require_once(MOBILE_IMAGE_INC_PATH . "/image_converter.inc");
* output buffering 用コールバック関数
if ($carrier !== FALSE) {
$pattern = '/<img\s+[^<>]*src=[\'"]?([^>"\'\s]+)[\'"]?\s*\/?/i';
while (($data = fgetcsv($fp, 1000, ",")) !== FALSE) {
if ($data[1] == $model || $data[1] == '*') {
$imageFileSize = $data[7];
// docomoとsoftbankの場合は画像ファイル一つに利用可能なサイズの上限を計算する
// auはHTMLのbyte数上限に画像ファイルサイズが含まれないのでimageFileSizeのまま。
if ($carrier == "docomo" or $carrier == "softbank") {
if( $result != false && $result > 0){
// 計算式:(利用端末で表示可能なcacheサイズ - HTMLのバイト数 - 変換後の画像名のバイト数(目安値) ) / HTML中の画像数
$temp_imagefilesize = ($cacheSize - strlen($buffer) - (140 * $result) ) / $result;
// 計算式:(利用端末で表示可能なcacheサイズ - HTMLのバイト数 )
$temp_imagefilesize = ($cacheSize - strlen($buffer) );
// 計算結果が端末の表示可能ファイルサイズ上限より小さい場合は計算結果の値を有効にする
if ($temp_imagefilesize < $imageFileSize) {
$imageFileSize = $temp_imagefilesize;
$imageConverter = New ImageConverter();
$imageConverter->setOutputDir(MOBILE_IMAGE_DIR);
$imageConverter->setImageType($imageType);
$imageConverter->setImageWidth($imageWidth);
$imageConverter->setImageHeight($imageHeight);
$imageConverter->setFileSize($imageFileSize);
// HTML中のIMGタグを変換後のファイルパスに置換する
foreach ($images[1] as $key => $value) {
$converted = $imageConverter->execute(preg_replace('|^' . URL_DIR . '|', HTML_PATH, $value));
if (isset ($converted['outputImageName'])) {
$buffer = str_replace($value, MOBILE_IMAGE_URL . '/' . $converted['outputImageName'], $buffer);
$buffer = str_replace($images[0][$key], '<!--No image-->', $buffer);
Documentation generated on Fri, 24 Feb 2012 14:00:17 +0900 by Seasoft
|